/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.entity.changeset;

import java.util.Objects;

public class Tuple<T1, T2> {

  private T1 item1;
  private T2 item2;

  public Tuple(T1 item1, T2 item2) {
    this.item1 = item1;
    this.item2 = item2;
  }

  public T1 getItem1() {
    return item1;
  }

  public T2 getItem2() {
    return item2;
  }

  @Override
  public int hashCode() {
    return Objects.hash(item1, item2);
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null || !(obj instanceof Tuple)) {
      return false;
    }
    Tuple target = (Tuple) obj;
    return (item1 != null ? item1.equals(target.getItem1()) : target.getItem1() == null) && (
        item2 != null ? item2.equals(target.getItem2()) : target.getItem2() == null);
  }
}
